//
//  HD_HSP_OnlyMap_ViewController.m
//  HDLiaoNingMeseum
//
//  Created by HDHaoShaoPeng on 2017/8/8.
//  Copyright © 2017年 HDNiuKuiming. All rights reserved.
//

#import "HD_HSP_OnlyMap_ViewController.h"
#import "HDMapView.h"
#import "UIView+Extension.h"
#import "HDDeclare.h"


@interface HD_HSP_OnlyMap_ViewController ()
<HDMapViewDataSource,HDMapViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *mapBottomView;

@property(weak,nonatomic)HDDeclare *declare;
@property(strong,nonatomic)HDMapView *myMapView;
@end

@implementation HD_HSP_OnlyMap_ViewController

{
    int _floorNum;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _floorNum = 1;
}

-(void)viewDidAppear:(BOOL)animated
{
    if (!_myMapView) {
        [self.mapBottomView addSubview:self.myMapView];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

#pragma mark - 点击方法

- (IBAction)chooseFloorClicked:(id)sender {
    
}

- (IBAction)showRoadClicked:(id)sender {
    
}

- (IBAction)backClicked:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark - 懒加载
-(HDMapView *)myMapView
{
    if (!_myMapView) {
        CGSize mapSize = CGSizeMake(465, 320);
        _myMapView = [[HDMapView alloc] initWithFrame:self.mapBottomView.frame contentSize:mapSize];
        _myMapView.dataSource = self;
        _myMapView.mapViewdelegate = self;
        _myMapView.levelsOfZoom = 2;
        _myMapView.levelsOfDetail = 2;
    }
    return _myMapView;
}

-(HDDeclare *)declare
{
    if (!_declare) {
        _declare = [HDDeclare sharedDeclare];
    }
    return _declare;
}

#pragma mark - mapViewSource delegate

- (UIImage *)mapView:(HDMapView *)mapView
         imageForRow:(NSInteger)row
              column:(NSInteger)column
               scale:(NSInteger)scale
{
    NSString *folderName = @"125";
    if (scale == 2)
        folderName = @"250";
    else if (scale == 4)
        folderName = @"500";
    else if (scale == 8)
        folderName = @"1000";
    
    
    
    NSString *name = [NSString stringWithFormat:@"%@/tileView/%@/%d/%@/1_%@_%ld_%ld.png",self.declare.catch_path,self.declare.language,_floorNum,folderName, folderName,(long)column, (long)row];
    UIImage *myImage = [UIImage imageWithContentsOfFile:name];
    
    
    
    return myImage;
}

@end
